package com.yunhe.transfer.controller.data;

import com.yunhe.common.model.ResultObject;
import com.yunhe.transfer.service.data.HeartbeatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 心跳Controller
 * @author liuronglei
 */
@RestController
@RequestMapping("/heartbeat")
public class HeartbeatController {
    @Autowired
    private HeartbeatService heartbeatService;

    @RequestMapping(value = "/heartbeat", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> heartbeat(@RequestParam("stationCode") Long stationCode) {
        // 点号由云端根据规则自动生成
        heartbeatService.updateHeartbeatTimeMillis(stationCode);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }
}
